﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Cqrs.Common
{

    public class State
    {

        // This is a collection of events, with the resulting state that would occur.
        private Dictionary<string, Transition> _transitions =
            new Dictionary<string, Transition>();

        public State(string name)
        {
            this.Name = name;
        }

        public string Name { get; private set; }

        [JsonIgnore]
        public Dictionary<string, Transition> Transitions
        {
            set
            {
                _transitions = value;
            }
            get
            {
                return _transitions;
            }
        }
        
        
        public void AddTransition(string command, string @event, string state)
        {
            _transitions.Add(@event,
                new Transition(command, @event, state));
        }
    }
}
